# -*- coding: utf-8 -*-
# @Time    : 2022/7/16 14:49
# @Author  : catherine
# @Email   : catherine_csq@163.com
# @File    : customer_home_page.py
# @Software: PyCharm
from selenium.webdriver.common.by import By

from pages.base_page import BasePage


class CustomerHomePage(BasePage):
    '''客户首页类'''
    url="http://192.168.189.1:8081/crm/index.php?m=customer"
    #定位器
    add_customer_locator = (By.XPATH, '/html/body/div[5]/div[2]/div[1]/div/a')
    edit_customer_locator = (By.XPATH, '//*[@id="form1"]/table/tbody/tr[1]/td[12]/a[2]')
    selected_customer_locator = (By.XPATH, '//*[@id="form1"]/table/tbody/tr[1]/td[1]/input')
    mass_operate_locator = (By.XPATH, '/html/body/div[5]/div[2]/div[1]/ul/div/a')
    delete_locator = (By.ID, 'delete')
    customer_pool_locator = (By.XPATH, '/html/body/div[5]/div[1]/ul/li[2]/a')
    contacts_locator = (By.XPATH, '/html/body/div[5]/div[1]/ul/li[3]/a')
    customer_care_locator = (By.XPATH, '/html/body/div[5]/div[1]/ul/li[4]/a')


    def click_add_customer(self):
        '''新建客户，将进入新建客户界面'''
        self.find_element(self.add_customer_locator).click()

    def click_edit_customer(self):
        '''点击编辑，将进入编辑客户信息界面'''
        self.find_element(self.edit_customer_locator).click()

    def click_selected_customer(self):
        '''勾选列表第一个客户'''
        self.find_element(self.selected_customer_locator).click()

    def click_mass_operate(self):
        '''点击批量操作'''
        self.find_element(self.mass_operate_locator).click()

    def click_delete(self):
        '''删除客户'''
        self.find_element(self.delete_locator).click()
        self.driver.switch_to.alert.accept()

    def click_customer_pool(self):
        '''进入客户池界面'''
        self.find_element(self.customer_pool_locator).click()

    def click_contacts(self):
        '''进入联系人界面'''
        self.find_element(self.contacts_locator).click()

    def click_customer_care(self):
        '''进入客户关怀界面'''
        self.find_element(self.customer_care_locator).click()
